package com.xizimall.rest.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.xizimall.rest.dao.JedisClient;
import com.xizimall.rest.service.RedisService;
import com.xizimall.common.pojo.XizimallResult;
import com.xizimall.common.utils.ExceptionUtil;
@Service
public class RedisServiceImpl implements RedisService {
    @Autowired
    private JedisClient jedisClient;
    
    @Value("${INDEX_CONTENT_REDIS_KEY}")
	private String INDEX_CONTENT_REDIS_KEY;
    
    @Value("${INDEX_ITEMCAT_REDIS_KEY}")
	private String INDEX_ITEMCAT_REDIS_KEY;
    
	@Override
	public XizimallResult syncContent(long contentId) {
		try {
			jedisClient.hdel(INDEX_CONTENT_REDIS_KEY, contentId+"");
			
		} catch (Exception e) {
			e.printStackTrace();
			return XizimallResult.build(500, ExceptionUtil.getStackTrace(e));
		}
		return XizimallResult.ok();
	}

	@Override
	public XizimallResult syncItemCat(long parentId) {
		try {
			jedisClient.hdel(INDEX_ITEMCAT_REDIS_KEY, parentId+"");
		} catch (Exception e) {
			e.printStackTrace();
			return XizimallResult.build(500, ExceptionUtil.getStackTrace(e));
		}
		return XizimallResult.ok();
	}

}
